package annotation.delegate

import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

class A {
	def a = "aaa"
	def printA() { println a }
}

class B {

	@Delegate A field
	def b = "bbb"
	def printB() { println b }
}
aaa = new A()
b = new B(field:aaa)

b.printB()
b.printA()

class LockableList {
	@Delegate private List list = []
	@Delegate private Lock lock = new ReentrantLock()
}


def list = new LockableList()


list.lock()
try {
	list << 'Groovy'
	list << 'Grails'
	list << 'Griffon'
} finally {
	list.unlock()
}


assert list.size() == 3
assert list instanceof Lock
assert list instanceof List